package com.youjiang.meeting.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youjiang.meeting.mapper.OrdersMapper;
import com.youjiang.meeting.po.Orders;
import com.youjiang.meeting.po.OrdersExample;
import com.youjiang.meeting.service.OrderService;

@Service
public class OrderServiceImpl implements OrderService {

	@Autowired
	private OrdersMapper oMapper;
	
	@Override
	public void insertOrder(Orders order) {
		// TODO Auto-generated method stub
		oMapper.insert(order);
	}

	@Override
	public Orders findOrderByOut_trade_no(String out_trade_no) {
		// TODO Auto-generated method stub
		OrdersExample example = new OrdersExample();
		OrdersExample.Criteria criteria = example.createCriteria();
		criteria.andOutTradeNoEqualTo(out_trade_no);
		List<Orders> orders = oMapper.selectByExample(example);
		Orders order = null;
		if(orders!=null && orders.size()>0){
			order = orders.get(0);		
		}
		return order;
	}

	@Override
	public void updateOrder(Orders order) {
		// TODO Auto-generated method stub
		oMapper.updateByPrimaryKey(order);
	}

}
